package com.auth.manage.web.handler;

import com.auth.manage.base.exception.BizException;
import com.auth.manage.web.vo.Result;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalWebExceptionHandler {

    @ResponseStatus(HttpStatus.OK)
    @ExceptionHandler(BizException.class)
    public Result handlerBizException(BizException bizException){
        Result result = Result.builder().
                code(bizException.getErrorCode().getCode()).
                msg(bizException.getMessage()).
                success(false).
                build();
        return result;
    }

}
